﻿CREATE TABLE [registration].[Registration] (
    [RegistrationID]             INT          IDENTITY (1, 1) NOT NULL,
    [RegistrationTypeID]         INT          NULL,
    [ApplicationDate]            DATETIME     NULL,
    [CompletionDate]             DATETIME     NULL,
    [TitleID]                    INT          NULL,
    [VehicleID]                  INT          NULL,
    [PlateID]                    INT          NULL,
    [OdometerReading]            INT          NULL,
    [OdometerReadingTypeID]      INT          NULL,
    [RegistrationExpirationDate] DATETIME     NULL,
    [CreatedBy]                  VARCHAR (50) NULL,
    [CreatedDate]                DATETIME     NULL,
    [UpdatedBy]                  VARCHAR (50) NULL,
    [UpdatedDate]                DATETIME     NULL,
    [EndDate]                    DATETIME     NULL,
    CONSTRAINT [PK_Registration] PRIMARY KEY CLUSTERED ([RegistrationID] ASC),
    CONSTRAINT [FK_Registration_OdometerReadingType] FOREIGN KEY ([OdometerReadingTypeID]) REFERENCES [registration].[OdometerReadingType] ([OdometerReadingTypeID]),
    CONSTRAINT [FK_Registration_Plate] FOREIGN KEY ([PlateID]) REFERENCES [plate].[Plate] ([PlateID]),
    CONSTRAINT [FK_Registration_RegistrationType] FOREIGN KEY ([RegistrationTypeID]) REFERENCES [registration].[RegistrationType] ([RegistrationTypeID]),
    CONSTRAINT [FK_Registration_Title] FOREIGN KEY ([TitleID]) REFERENCES [title].[Title] ([TitleID]),
    CONSTRAINT [FK_Registration_Vehicle] FOREIGN KEY ([VehicleID]) REFERENCES [vehicle].[Vehicle] ([VehicleID])
);

